package com.zh.elec.web.actions;

import java.util.List;

import com.zh.elec.model.FactoryAddress;
import com.zh.elec.model.ProductType;
import com.zh.elec.service.FactoryAddressService;
import com.zh.elec.service.ProductTypeService;
import com.zh.elec.web.actions.base.AbstractAction;

/**
 * 商品类型
 * @author scy
 *
 */
public class ProductTypeAction extends AbstractAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3888862817020088656L;
	private ProductTypeService productTypeService;
	private FactoryAddressService factoryAddressService;
	private ProductType productType;
	private List<ProductType> list;
	private List<FactoryAddress> listFactoryAddress;
	
	/**
	 * 添加
	 * @return
	 */
	public String save(){
		if(productType != null){
			productType = (ProductType)productTypeService.save(productType);
			return "success";
		}else{
			listFactoryAddress = factoryAddressService.findAll();
		}
		return "add";
	}
	/**
	 * 修改
	 * @return
	 */
	public String update(){
		productType = (ProductType)productTypeService.update(productType);
		return "success";
	}
	/**
	 * 删除
	 * @return
	 */
	public String del(){
		productType = (ProductType)productTypeService.del(productType);
		return "success";
	}
	/**
	 * 查询
	 * @return
	 */
	public String find(){
  		list = productTypeService.findAll();
		return "success";
	}
	/**
	 * 根据name查询
	 * @return
	 */
	public String findByName(){
		String name = "";
		String value= "";
		List<ProductType> list = productTypeService.findByName(name, value);
		System.out.println(list.size());
		return "success";
	}
	
	public ProductType getProductType() {
		return productType;
	}
	public void setProductType(ProductType productType) {
		this.productType = productType;
	}
	public void setProductTypeService(ProductTypeService productTypeService) {
		this.productTypeService = productTypeService;
	}
	public ProductTypeService getProductTypeService() {
		return productTypeService;
	}
	
	public FactoryAddressService getFactoryAddressService() {
		return factoryAddressService;
	}
	public void setFactoryAddressService(FactoryAddressService factoryAddressService) {
		this.factoryAddressService = factoryAddressService;
	}
	public List<ProductType> getList() {
		return list;
	}
	public void setList(List<ProductType> list) {
		this.list = list;
	}
	public List<FactoryAddress> getListFactoryAddress() {
		return listFactoryAddress;
	}
	public void setListFactoryAddress(List<FactoryAddress> listFactoryAddress) {
		this.listFactoryAddress = listFactoryAddress;
	}
	
}
